package weak_20241227_29.stream;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @author zdl
 * @date 2024/12/27
 */
public class Demo22 {
    public static void main(String[] args) {
        //22. 将字符串列表转换为Map，其中键是字符串，值是字符串长度
        ArrayList<String> list = new ArrayList<>();
        list.add("asd");
        list.add("qweq");
        list.add("rfs");
        list.add("pklj");
        Map<String, Integer> collect = list.stream().collect(Collectors.toMap(s -> s, s -> s.length()));
        System.out.println(collect);

    }
}
